class Solution(object):
    def addBinary(self, a, b):
        """
        :type a: str
        :type b: str
        :rtype: str
        """
        a = a[::-1]
        b = b[::-1]
        c = []
        carry = 0
        for i in range(max(len(a), len(b))):
            if i<len(a) and i<len(b):
                ca = int(a[i])
                cb = int(b[i])
                ret = carry+ca+cb
                carry = 1 if ret>1 else 0
                c.append(str(ret%2))
            elif i<len(a):
                ca = int(a[i])
                ret = carry+ca
                carry = 1 if ret>1 else 0
                c.append(str(ret%2))
            else:
                cb = int(b[i])
                ret = carry+cb
                carry = 1 if ret>1 else 0
                c.append(str(ret%2))
        if carry==1:
            c.append(str(carry))
        c.reverse()
        return "".join(c)

print(Solution().addBinary('11', '1'))